import upload from '@/utils/upload'
import request from '@/utils/request'

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword
  }
  return request({
    url: '/system/user/profile/updatePwd',
    method: 'put',
    params: data
  })
}

// 查询用户个人信息
export function getUserProfile() {
  return request({
    url: '/system/user/profile',
    method: 'get'
  })
}

// 修改用户个人信息
export function updateUserProfile(data) {
  return request({
    url: '/system/user/profile',
    method: 'put',
    data: data
  })
}

// 用户头像上传
export function uploadAvatar(data) {
  return upload({
    url: '/system/user/profile/avatar',
    name: data.name,
    filePath: data.filePath
  })
}


// 注册新用户
export function registerUser(data) {
  return request({
    url: '/register',
    data: data,
    method: 'post'
  })
}

// 注册员工和客户
export function addUser(data) {
  return request({
    url: '/system/user',
    data: data,
    method: 'post'
  })
}

// 删除用户
export function delUser(userId) {
  return request({
    url: '/system/user/' + userId,
    method: 'delete'
  })
}

// 获取用户列表
export function getUserList(data) {
    return request({
        url: '/system/user/list',
        data: data,
        method: 'get'
    })
}

// 获取用户列表
export function getCusList(data) {
    return request({
        url: '/system/user/typeList',
        data: data,
        method: 'get'
    })
}


// 修改用户信息
export function updateUser(data) {
    return request({
        url: '/system/user',
        data: data,
        method: 'put'
    })
}

